import Vue from 'vue'
import VueRouter from 'vue-router'

// 静态路由的导入
import login from '@/router/static/login'
import home from '@/router/static/home'

// 动态路由的导入
import approvalsRouter from './dynamicModules/approvals'
import departmentsRouter from './dynamicModules/departments'
import employeesRouter from './dynamicModules/employees'
import permissionRouter from './dynamicModules/permission'
import attendancesRouter from './dynamicModules/attendances'
import salarysRouter from './dynamicModules/salarys'
import settingRouter from './dynamicModules/setting'
import socialRouter from './dynamicModules/social'

// 组合动态路由模块
export const dynamicModules = [
  approvalsRouter,
  departmentsRouter,
  employeesRouter,
  permissionRouter,
  attendancesRouter,
  salarysRouter,
  settingRouter,
  socialRouter
]

Vue.use(VueRouter)

const staticRouter = [login, home]

const routes = [
  { path: '/', redirect: '/login', hidden: true },
  ...staticRouter,
  ...dynamicModules,
  { path: '/404', component: () => import('@/views/404.vue'), hidden: true },
  { path: '*', redirect: '/404', hidden: true }
]

const router = new VueRouter({
  mode: 'history',
  routes
})

export default router
